#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import rospy
from learn_topic_userdef.msg import Product

class ProductPub:
    def __init__(self):
        rospy.init_node('product_publisher', anonymous=True)
        self.pub = rospy.Publisher('product_info', Product, queue_size=10)
        self.pub_rate = rospy.Rate(10)

    def msg_publish(self):
        while not rospy.is_shutdown():
            product_msg = Product()
            product_msg.name = "Vehicle"
            product_msg.type = Product.industrial_grade
            product_msg.function = "Let human beings go further"
            self.pub.publish(product_msg)
            rospy.loginfo("Publish product info: name:%s,type:%d,function:%s", product_msg.name, product_msg.type, product_msg.function)
            self.pub_rate.sleep()

if __name__ == '__main__':
    try:
        node = ProductPub()
        node.msg_publish()
    except rospy.ROSInterruptException:
        pass